home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
COMAL
/
B-Book Series
/
(k)b4.d64
/
example11.2
< prev
next >
Wrap
Text File
|
2007-02-28
|
1KB
|
50 lines
0010 DIM LIFE$(15) OF 15, CHANGE$(15) OF 15
0020 FOR ROW:=1 TO 15 DO
0040 LIFE$(ROW)(1:15):=" "
0050 CHANGE$(ROW)(1:15):=" "
0070 ENDFOR ROW
0080 READ ROW,COL
0090 WHILE ROW>0 AND COL>0 DO
0100 LIFE$(ROW)(COL):="*"
0110 READ ROW,COL
0120 ENDWHILE
0130 PRINTIT
0140 REPEAT
0150 FLAG:=0
0160 FOR ROW:=2 TO 14 DO
0165 CHANGE$(ROW)(1:15):=" "
0170 FOR COL:=2 TO 14 DO
0180 TEST(ROW,COL)
0190 ENDFOR COL
0200 ENDFOR ROW
0210 IF FLAG=0 THEN
0220 PRINT "ALL DEAD"
0230 STOP
0240 ENDIF
0250 FOR ROW:=1 TO 15 DO
0270 LIFE$(ROW)(1:15):=CHANGE$(ROW)(1:15)
0290 ENDFOR ROW
0300 PRINTIT
0310 UNTIL 2=1
0320 PROC PRINTIT
0330 PRINT CHR$(147)
0340 FOR ROW:=1 TO 15 DO
0370 PRINT TAB(20),LIFE$(ROW)(1:15)
0430 ENDFOR ROW
0440 ENDPROC PRINTIT
0450 PROC TEST(ROW,COL)
0460 COUNT:=0
0470 FOR C:=COL-1 TO COL+1 DO
0480 IF LIFE$(ROW-1)(C)="*" THEN COUNT:=COUNT+1
0490 IF LIFE$(ROW+1)(C)="*" THEN COUNT:=COUNT+1
0510 ENDFOR C
0520 IF LIFE$(ROW)(COL-1)="*" THEN COUNT:=COUNT+1
0530 IF LIFE$(ROW)(COL+1)="*" THEN COUNT:=COUNT+1
0540 IF COUNT=3 OR (COUNT=2 AND LIFE$(ROW)(COL)="*") THEN
0550 CHANGE$(ROW)(COL):="*"
0560 FLAG:=1
0570 ENDIF
0580 ENDPROC TEST
0590 DATA 6,6,6,7,6,8,6,9,6,10,7,6,7,10,8,6,8,10,9,6,9,10,10,6,10,7
0600 DATA 10,6,10,7,10,8,10,9,10,10,-1,-1